<template>
	<om-page :title="pageTitle" class="om-font-size" style="height: 100vh;padding-top: 40rpx;">
		<om-button :buttons="buttons" @btnChange="btnChange"></om-button>
		<view v-show="signList.length > 0" style="position: fixed;top: 0rpx; width: 100%;display: flex; flex-direction: column; justify-content: space-evenly;z-index: 100;">
			<image v-for="(item,index) in signList" :key="index"  :src="item" style="width: 40%;" alt="" mode="widthFix"/>
		</view>
		<view v-show="tipMsg" class="" style="position: fixed; top: 48%;width: 100%;text-align: center;">
			{{tipMsg}}
		</view>
		<view class="page__bd" style="margin:10px;padding-bottom:120rpx;">
			<view style="display: flex;align-items:center;justify-content: center;" class="padding-top-sm">
				<view class="text-df">{{orgName}}</view>
			</view>
			<view class="om-show-hd">
				<view class="text-xl">{{formName}}</view>
			</view>
			<!-- 主表信息 -->
			<view v-if="showData">
				<view v-for="(item, index) in showData" :key="index" style="display: block;">
					<view v-if="hasValue(item.value) || showAll">
						<view class="tui-flex">
							<view class="flex justify-end tui-col-4 show-label"> 
								<text v-if="changeTitles[item.name] &&item.value.toString() !=='false'" class="om-font-size">
									{{changeTitles[item.name]}}
								</text>
								<text v-else class="om-font-size">{{ item.name }}</text>
							</view>
							<view class="tui-col-8" style="white-space:pre-wrap;display:flex;align-items:flex-end;">
								<button class="bg-blue" v-if="item.isfile" size="mini" @click="openFile(item)">查看</button>
								<text selectable="true" v-else>{{ hasValue(item.value)&&item.value.toString() !=='false' ? (item.value.toString() === 'true'?'√':item.value.toString()) : '' }}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view v-if="subTitles">
				<view v-for="(title, index) in subTitles" :key="index">
					<view v-if="showDataMap[title] && showDataMap[title].length && titleItemNum[title]">
						<om-sub :isCard="true" :title="changeTitles[title]?changeTitles[title]:title">
							<view slot="extra" class="flex" v-show="titleButtonMap[title] && titleButtonMap[title].length>0">
								<view v-for="(subbtn,subindexs) in titleButtonMap[title]" :key="subindexs">
									<button class="om-font-size-xs subbtn" @click="useHandle(subbtn.onClick)">{{ subbtn.text }}</button>
								</view>
							</view>
							<view v-for="(item, showIndex) in showDataMap[title]" :key="showIndex" style="display: block">
								<view v-if="(hasValue(item.value) &&item.value.toString() !=='false')|| showAll">
									<view v-if="showDataMap[title].length == 1" class="tui-flex">
										<view class="tui-col-1"></view>
										<view class="tui-col-11">
											<button class="bg-blue" v-if="item.isfile" size="mini" @click="openFile(item)">查看</button>
											<text  selectable="true" class="remarkTable" style="white-space:pre-wrap; word-wrap: break-word;" v-else v-html="hasValue(item.value) &&item.value.toString() !=='false' ? (item.value.toString() === 'true'?'√':item.value.toString()) : '' "></text>
										</view>
									</view>
									<view v-else class="flex" >
										<view class="justify-end tui-col-4 show-label om-font-size" >
											<text class="om-font-size flex justify-end">{{getName(item)}}</text>
										</view>
										<view class="tui-col-8 flex justify-start align-center">
											<button class="bg-blue" v-if="item.isfile" size="mini" @click="openFile(item)">查看</button>
											<text selectable="true"  v-else style="word-break: break-all; white-space:initial ;"class="flex  justify-start" v-html="hasValue(item.value) &&item.value.toString() !=='false' ? (item.value.toString() === 'true'?'√':item.value.toString()) : '' "></text>
										</view>
									</view>
								</view>
							</view>
						</om-sub>
					</view>
					<view v-else-if="showColumnOrderDataMap[title]" style="position: relative;">
						<om-sub :isCard="true" :title="changeTitles[title]?changeTitles[title]:title">
							<view class="tip"></view>
							<view style="overflow-x: scroll;" v-show="showAll">
								<view style="display: flex;" v-for="(item, zIndex) in showColumnOrderDataAll[index]" :key="zIndex">
									<view v-for="(sitem, sIndex) in item" :key="sIndex" style="display: flex;flex-shrink: 0;width: 320px;">
										<view style="width: 120px;">
											<view class="show-label" style="font-size: 16px;">{{getName(sitem)}}</view>
										</view>
										<view style="width: 200px;display: flex;">
											<button class="bg-blue" v-if="sitem.isfile" size="mini" @click="openFile(sitem)">查看</button>
											<text selectable="true"  v-else style="white-space:pre-wrap; word-wrap: break-word;align-items: center;" v-html="hasValue(sitem.value) &&sitem.value.toString() !=='false' ? (sitem.value.toString() === 'true'?'√':sitem.value.toString()) : '' "></text>
										</view>
									</view>
								</view>
							</view>
							<view style="overflow-x: scroll;" v-show="!showAll">
								<view style="display: flex;" v-for="(item, zIndex) in showColumnOrderDataPart[index]" :key="zIndex">
									<view v-for="(sitem, sIndex) in item" :key="sIndex" style="display: flex;flex-shrink: 0;width: 320px;">
										<view style="width: 120px;">
											<view class="show-label" style="font-size: 16px;">{{getName(sitem)}}</view>
										</view>
										<view style="width: 200px;display: flex;">
											<button class="bg-blue" v-if="sitem.isfile" size="mini" @click="openFile(sitem)">查看</button>
											<text selectable="true" v-else style="white-space:pre-wrap; word-wrap: break-word;align-items: center;" v-html="hasValue(sitem.value) &&sitem.value.toString() !=='false' ? (sitem.value.toString() === 'true'?'√':sitem.value.toString()) : '' "></text>
										</view>
									</view>
								</view>
							</view>
						</om-sub>
					</view>
					<view v-else-if="showListMap[title] && showListMap[title].length && titleItemNum[title]">
						<om-sub :isCard="true" :title="changeTitles[title]?changeTitles[title]:title" >
							<view slot="extra" class="flex" v-show="titleButtonMap[title] && titleButtonMap[title].length>0">
								<view v-for="(subbtn,subindexs) in titleButtonMap[title]" :key="subindexs">
									<button class="om-font-size-xs subbtn om-btn-color" @click="useHandle(subbtn.onClick)">{{ subbtn.text }}</button>
								</view>
							</view>
							<view slot="extra" class="flex" style="width:50px;" @click="analytics(title)" >
								<view class="cuIcon-refresh" style="margin-right:px;">
									{{showForm?'明细':'列表'}} 
								</view>
							</view>
							<!-- table子表 -->
							<view v-if="showForm">
								<ot-table  @onClick='onclick'  textAlign="left" titleTextAlign="left" :tableData="tableData[title]" :columns="tableColumns[title]"
								 :stickSide="stickSideTable[title]">
								</ot-table>
							</view>
							<!-- 子表信息 -->
							<view v-else class="margin-top-xs">
								<view class="show-block" v-for="(show, subIndex) in showListMap[title]" :key="subIndex">
									<om-divider :gap="[10, 10]" lineColor="#ddd" :lineSize="2"></om-divider>
									<view class="show-title padding-left padding-top-xs" style="font-size: 16px;">明细{{ subIndex + 1 }}</view>
									<view v-for="(item, itemIndex) in show" :key="itemIndex" style="display: block;">
										<view v-if="hasValue(item.value) || showAll || item.field == 'a' ">
											<view class="tui-flex">
												<view class="tui-flex  justify-end tui-col-4 show-label" >
													<text class="om-font-size flex  justify-end">{{getName(item)}}</text>
												</view>
												<view class="tui-col-8  flex justify-start align-center">
													<button class="bg-blue" v-if="item.isfile || isArray(item.value)" size="mini" @click="openFile(item)">查看</button>
													<button class="bg-blue" v-else-if="item.field == 'a'" size="mini" @click="onclick({},{url:item.tipUrl})">查看</button>
													<text v-else class="flex  justify-start" >{{ hasValue(item.value)&&item.value.toString() !=='false'  ? (item.value.toString() === 'true'?'√':item.value.toString()) : '' }}</text>
												</view>
											</view>
										</view>
									</view>
								</view>
							</view>
						</om-sub>
					</view>
					<view v-else-if="showAll">
						<om-sub isCard :title="changeTitles[title]?changeTitles[title]:title">
							<text class="flex justify-center">无</text>
						</om-sub>
					</view>
				</view>
				<!-- 表尾信息 -->
				<view v-if="showTailData.length" style="background-color: #ffffff;">
					<om-divider :gap="[20, 10]" lineColor="#eee" :lineSize="6"></om-divider>
					<view v-for="(item, index) in showTailData" :key="index" style="display: block;">
						<view v-if="hasValue(item.value) || showAll">
							<view class="tui-flex">
								<view class="flex justify-end tui-col-4 show-label">
									<text class="om-font-size" v-if="changeTitles[item.name]">
										{{changeTitles[item.name]}}
									</text>
									<text class="om-font-size" v-else>{{ item.name }}</text>
								</view>
								<view class="flex justify-start  align-center tui-col-8">
									<button class="bg-blue" v-if="item.isfile" size="mini" @click="openFile(item)">查看</button>
									<text v-else>{{ hasValue(item.value) ? (item.value.toString() === 'true'?'√':item.value.toString()) : '' }}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<!-- <om-hover-button url="/pages/main/main/main" openType="switchTab" title="返回首页"></om-hover-button> -->
		
		<uni-popup ref="popup" :type="'center'" :mask-click="false">
			<view class="padding" style="background-color: white;border-radius: 10px;">
				<view class="wpopup-item-sign padding-bottom-xs margin-top flex align-center">
					<text class="">
						签名：
					</text>
					<text v-if="!image" class="" :style="{color:changeColor?'red':'gray'}"  style="text-align: left; color: gray;width: 70%;"  @click="signClick">
						{{tips}}
					</text>
					<image v-else @click="imageClick" :src="captchaSrc(image)"  mode="widthFix" style="width: 60%; height:100%"></image>
					<uni-icons v-if="image" @click="clearImage"  :size="20"  style="margin-left: auto;" class="uni-icon-wrapper" color="#bbb" type="clear" />
					<uni-icons v-else :size="20"  style="margin-left: auto;" class="uni-icon-wrapper" color="#bbb" type="arrowright" />
				</view>
				<view class="wpopup-item padding-top" >
					<text class=" paddiong">
						备注：
					</text>
					<textarea  :maxlength="300" v-model="remark"  style="margin: 5px 0px 10px 0px;" placeholder-style="" placeholder='请输入300字以内' auto-height />
				<view class="" style="position: absolute; right:35rpx ; ">{{ remark.length }}/300</view>
				</view>
				<view class="flex justify-center" >
					<text @click="save"  class="margin-top om-color">
						确认
					</text>
					<text @click="cancel"  class="margin-top" style="margin-left: 20%;">
						取消
					</text>
				</view>
			</view>
		</uni-popup>
	</om-page>
	
</template>

<script>
	import {
		buttonShow
	} from '@/static/js/buttonShow.js';
	import {
		confirmModal,
		errorModal,
		getCharLength,
		getUrl,
		isEnglish,
		filterNumbers
	} from '@/static/js/common.js';
import { mapState } from 'pinia';
import {
		useLoginUserStore
	} from '@/stores/login-user.js';
	import {
		hasValue
	} from '@/static/js/formUtil.js';
	const app = getApp();
	
	export default {
		provide() {
			return {
				show: this
			};
		},
		data() {
			return {
				orgName:'',
				formName:'O&M',
				showAll:false,
				scrollTop: 0,
				fabButtons: [],
				changeTitles: {},
				changeNames: {},
				buttons: [],
				steps: [],
				subTitles: [],
				stepDesc: '',
				showListMap: {},
				showColumnOrderDataMap: {},
				showColumnOrderDataAll: [],
				showColumnOrderDataPart: [],
				showData: [],
				showTailData: [],
				showDataMap: {},
				titleButtonMap: {},
				titleItemNum: {},
				logoColor: '',
				formId: 0, //表单ID
				busCode: '', //业务职能编码
				orgId: '', //组织ID
				isOuter: false,
				active: -1, //当前激活步骤
				pageTitle: '',
				tableData: {},
				tableColumns: {},
				showTable: {}, //子表是否显示表格
				stickSideTable: {},//是否固定列
				timer: '',
				formIndex:0,
				pendingList:[],
				time:'' ,//用于计算在当前页浏览时间
				second:'',
				top:50,
				left:300,
				screenWidth:0,
				storageKey:'signature-key',
				image:'',
				wechatHistoryId:'',
				showBtn:false,
				remark:'',
				bottomTips:'请在框中书写，签名仅限于业务信息接收确认',
				signName:'',
				goToOld:false,
				accessToken:null,
				showForm:true,
				canReturn:false,
				signList:[],
				changeColor:false,
				tips:'点击签名',
				lastReturnTime:'',
				tipMsg:''
			};
		},
		computed: {
			...mapState(useLoginUserStore, ['userName', 'userId']),
			isArray(){
				return function(value){
				    if(Object.prototype.toString.call(value) == "[object Array]"){
						return true
					}else{
						return false
					}
				}    
			}
		},
		watch:{
		},
		methods: {
			onclick(row,col){
				let _that = this
				let url = col.url.substring(1,col.url.length)
				uni.navigateTo({
					url:'./showTable?url='+url
				})
			},
			btnChange(index){
				let _that = this
				_that[_that.buttons[index].func](index);
			},
			download(){
				let _that = this
				uni.navigateTo({
					url: './showImage?formCode='+_that.busCode+'&fileId='+_that.formId+'&isOuter='+_that.isOuter,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			getSignList(){
				let _that = this
				_that.om.request(
					'common/getSignList',
					{
						fileId:_that.formId,
						businessFormCode:_that.busCode
					}
				).then(res=>{
					if(res.succeed){
						let arr = []
						for(let item of res.value){
							let url = app.globalData.url + 'UPLOAD' + item
							arr.push(url)
						}
						_that.signList = arr
					}
				})
			},
			save(){
				let _that = this
				if(!_that.image){
					_that.tips = '请先完成签名'
					_that.changeColor = true
				}else{
					_that.om.request(
						'wechat/doRelatedPartyConfirm',
						{
							wechatHistoryId:_that.wechatHistoryId,
							sign:_that.image,
							remark:_that.remark
						},
						'post'
					).then(res=>{
						if(res.succeed){
							_that.cancel()
							if(_that.showBtn){
								_that.showBtn = false
							}
							setTimeout(() => {
							    uni.redirectTo({
							       url: '../wechat/wechat?fileId=' + _that.formId+'&busCode='+_that.busCode +'&orgId='+_that.orgId+'&wechatHistoryId='+_that.wechatHistoryId +'&receiveUserName='+_that.signName+'&isOuter='+_that.isOuter
							    });	
							}, 500)
						}else{
							_that.cancel()
							_that.om.toast(res.msg)
						}
					})
				}
				
			},
			boolRelatedPartyConfirm(){
				let _that = this
				_that.om.request(
					'wechat/boolRelatedPartyConfirm',
					{
						wechatHistoryId:_that.wechatHistoryId
					}
				).then(res=>{
					if(res.succeed){
						if(res.value.downloadButton){
							_that.buttons.push(
								{
									text: "下载",
									func: "download"
								}
							)
							_that.getSignList()
						}
						if(res.value.canConfirm){
							_that.showBtn = res.value.canConfirm
							_that.buttons.push(
								{
									text: "确认&签收",
									func: "confirm"
								}
							)
						}
						if(res.value.accessToken){
							_that.accessToken = res.value.accessToken
							try{
								uni.setStorageSync('baiduToken',res.value.accessToken)
							}catch(e){
								//TODO handle the exception
							}
						}
						if(res.value.receiveUserName){
							_that.signName = res.value.receiveUserName
						}
						if(res.value.canReturn){
							_that.canReturn = true
							if(_that.buttons.length > 0){
								_that.buttons.splice(1,1,{
									text: "弃签",
									func: "returnSign"
								})
							}else{
								_that.buttons.push(
									{
										text: "弃签",
										func: "returnSign"
									}
								)
							}
						}
						if(res.value.lastReturnTime){
							_that.om.toast('可在'+res.value.lastReturnTime +'前弃签',5000)
						}
					}else{
						_that.om.toast(res.msg)
					}
				})
			},
			imageClick(){
				let _that = this
				uni.previewImage({
					current: 1,
					urls: [_that.image]  // 是个 数组 单张的（[this.img]），所有的 this.imglist
					// urls: this.picarr,
				});
			},
			clearImage(){
				let _that = this
				uni.removeStorageSync(_that.storageKey)
				_that.image = ''
			},
			captchaSrc(image){
				return image.replace(/[\r\n]/g, "");
			},
			signClick(){
				let _that = this
				if(!_that.signName || isEnglish(_that.signName)){
					uni.navigateTo({
						url: "../../public/signature/signature?goToOld="+true
					})
				}else{
					let name = filterNumbers(_that.signName)
					uni.navigateTo({
						url: "../../public/signature/signature?bottomTips=" + _that.bottomTips + '&userName='+ name
					})
				}
			},
			cancel(){
				let _that = this
				_that.remark = ''
				_that.$refs.popup.close()
				setTimeout(()=>{
					_that.tips = '点击签名'
					_that.changeColor = false
				},500)
				_that.clearImage()
			},
			returnSign(){
				let _that = this
				_that.om.request(
					"wechat/doRelatedPartyReturn",
					{
						wechatHistoryId:_that.wechatHistoryId
					},
					'post'
				).then(res=>{
					confirmModal(_that,'提示信息','弃签后请通知相关方业务人员',()=>{
						setTimeout( () => {
							uni.redirectTo({
							   url: '../wechat/wechat?fileId=' + _that.formId+'&busCode='+_that.busCode +'&orgId='+_that.orgId+'&wechatHistoryId='+_that.wechatHistoryId +'&receiveUserName='+_that.signName+'&isOuter='+_that.isOuter
							});	
						}, 500)
					},()=>{})
				})
			},
			confirm(){
				let _that = this
				_that.$refs.popup.open()
			},
			showAllClick(){
				this.showAll = !this.showAll
			},
			hasValue(v){
				return hasValue(v, true)
			},
			trigger(e) {
				if (e.item.text === '返回顶部') {
					this.scrollTop = 0;
					uni.pageScrollTo({
						scrollTop: 0
					});
				}
			},
			openFile(item) {
				let _that = this
				if(Object.prototype.toString.call(item.value) == "[object Array]" && _that.busCode == 'DTM0201'){
						let url = getUrl("/pages/form/ckd-zb-anytimereport/showRelationList",{relationList:JSON.stringify(item.value)})
						uni.navigateTo({
							url: url
						})
				}else{
					if(item.fileUrl){
						uni.navigateTo({
							url: "/pages/public/filetable/filetable?fileUrl=" + encodeURIComponent(item.fileUrl)
						})
					} else {
						if(!item.multiFile && item.fileName && item.fileName.endsWith("pdf")){
							this.om.openPdf(item)
						}else{
							let subId = '',simpleClazzName='',fileId='',fieldId='',fileUplaodKey='';
							if (item.attr) {
								if(item.attr.subId)
									subId = item.attr.subId
								if(item.attr.simpleClazzName)
									simpleClazzName = item.attr.simpleClazzName
								if(item.attr.fileId)
									fileId = item.attr.fileId
								if(item.attr.fieldId)
									fieldId = item.attr.fieldId
								if(item.fileUplaodKey)
									fileUplaodKey = item.fileUplaodKey
							}
							if(item.fileList){
								uni.setStorageSync('showFileList',item.fileList);
							}
							uni.navigateTo({
								url: "/pages/public/filetable/filetable?busCode=" + _that.busCode + "&mainId=" + _that.formId + "&subId=" +
									subId + "&simpleClazzName="+simpleClazzName+"&fieldId="+fieldId+'&fileUplaodKey=' + fileUplaodKey
							})
						}
					}
				}
			},
			analytics(title) {
				let _that = this
				_that.showForm = !_that.showForm
			},
			loadFormInfo: function() {
				let _that = this;
				_that.om.request('wechat/getInfoDict', {
						fileId: _that.formId,
						formCode: _that.busCode,
						orgId:_that.orgId,
						isOuter:_that.isOuter,
						wechatHistoryId:_that.wechatHistoryId
					}).then(res => {
						let forminfo = res.value;
						_that.boolRelatedPartyConfirm()
						if(forminfo){
							if(forminfo.title)
							_that.formName = forminfo.title;
							_that.orgName = forminfo.orgName;
							_that.subTitles = forminfo.subTitles;
							_that.showListMap = forminfo.showListMap
							_that.showData = forminfo.showData;
							_that.showTailData = forminfo.showTailData;
							_that.showDataMap = forminfo.showDataMap;
							_that.titleButtonMap = forminfo.titleButtonMap;
							_that.titleItemNum = forminfo.titleItemNum;
							_that.changeTitles = forminfo.changeTitles || {};
							_that.changeNames = forminfo.changeNames || {};
							_that.title = forminfo.title;
							_that.showColumnOrderDataMap = forminfo.showColumnOrderDataMap;
							_that.tipMsg = forminfo.tipMsg
							let tarr = [];
							let ztarr = [];
							for(let i=0;i<_that.subTitles.length; i++){
								let showColumnOrderDataMapObj = _that.showColumnOrderDataMap[_that.subTitles[i]];
								if(showColumnOrderDataMapObj){
									let keyArr = Object.keys(showColumnOrderDataMapObj);
									let num = keyArr.length;
									let maxLength = 0;
									let arr = [];
									let showArr = [];
									let nmaxLength = 0;
									let zshowArr = [];
									for(let i=0; i<num; i++){
										let subData = showColumnOrderDataMapObj[keyArr[i]];
										let subDataLength = subData.length;
										if(subDataLength > maxLength){
											maxLength = subDataLength
										}
										let narr = [];
										for(let r=0; r<subDataLength; r++){
											if(subData[r].value){
												narr.push(subData[r])
											}
										}
										showArr.push(narr)
									}
									for(let m=0; m<maxLength; m++){
										let obArr = [];
										for(let n=0; n<num; n++){
											obArr.push(showColumnOrderDataMapObj[keyArr[n]][m] || {})
										}
										arr.push(obArr)
									}
									
									for(let s=0; s<num; s++){
										if(showArr[s].length > nmaxLength){
											nmaxLength = showArr[s].length
										}
									}
									for(let t=0; t<nmaxLength; t++){
										let zobArr = [];
										for(let q=0; q<num; q++){
											zobArr.push(showArr[q][t] || {})
										}
										zshowArr.push(zobArr)
									}
									
									tarr.push(arr)	
									ztarr.push(zshowArr)
								}else{
									tarr.push([])
									ztarr.push([])
								}
							}
							_that.showColumnOrderDataAll = tarr
							_that.showColumnOrderDataPart = ztarr
							_that.init();
						}else{
							
						}
					});
			},
			init() {
				let _that = this;
				if (_that.subTitles) {
					let objTable = {},objData = {},objColumns = {},objStickSideTable={};
					for (let i = 0; i < _that.subTitles.length; i++) {
						let title = _that.subTitles[i];
						let showlist = _that.showListMap[title];
						if (showlist && showlist.length) {
							objTable[title] = (this.subTableShowType == 0?false:true)  
							let data = []; //子表数据
							let column = []; //子表列标题
							let col = {} //
							for (let j = 0; j < showlist.length; j++) {
								let show = showlist[j];
								let o = {
									subTableIndex:j+1
								};
								if (show && show.length) {
									if (column.length == 0) {
										column.push({
											title:'序号',
											key: 'subTableIndex',
											width:90
										})
										for (let k = 0; k < show.length; k++) {
											let item = show[k]
											_that.wrapCol(item, o)
											let c = {
												title: _that.getName(item),//_that.changeTitles[item.name] ? _that.changeTitles[item.name] : item.name,
												key: item.field,
												width: Math.max(getCharLength(_that.getName(item)), getCharLength(item.value ? item.value.toString() : "")) * 12 +
													35
											}
											if(item.field == 'a' && item.tipUrl){
												c.url = item.tipUrl
												c.listenerClick = true
											}
											if(item.isfile){
												if(!item.multiFile && (item.fileName && item.fileName.endsWith("pdf")) ){
													c.isLink = {
														url: "/pages/public/pdf-preview/pdf-preview",
														params: ['url','busCode','fileId','fileUplaodKey']
													}
												}else{
													c.isLink = {
														url: "/pages/public/filetable/filetable",
														params: ['busCode','mainId','subId','simpleClazzName','url','fileId','fieldId','fileUplaodKey']
													}
												}
											}
											if(_that.busCode == 'DTM0201' && item.field == 'relationList'){
												c.isLink = {
													url: "/pages/form/ckd-zb-anytimereport/showRelationList",
													params:['showList']
												}
											}
											column.push(c)
											col[item.field] = c
										}
									} else {
										for (let k = 0; k < show.length; k++) {
											let item = show[k]
											_that.wrapCol(item, o)
											let width = getCharLength(item.value ? item.value.toString() : "") * 12 + 30
											if (!col[item.field] || !col[item.field].width) {} else {
												col[item.field].width = Math.max(col[item.field].width, (width>290?320:width+20))
											}
										}
									}
								}
								data.push(o)
							}
							objData[title] = data;
							objColumns[title] = column;
							objStickSideTable[title]=true
						}
					}
					_that.showTable = objTable;
					_that.tableData = objData;
					_that.tableColumns = objColumns;
					_that.stickSideTable = objStickSideTable
				}
			},
			getName(wxColumn){
				if(wxColumn.nameChange){
					let newName = this.changeNames[wxColumn.name]
					if(newName){
						return newName;
					}else{
						return wxColumn.name;
					}
				}else{
					return wxColumn.name;
				}
			},
			wrapCol(item, o){
				let _that = this
				if(item.value.toString()){
					if(item.value.toString() === 'true'){
						o[item.field] = '√'
					}else if(item.value.toString() === 'false'){
						o[item.field] = ''
					}else{
						if(Object.prototype.toString.call(item.value) == "[object Array]" && _that.busCode == 'DTM0201'){
							o['showList'] = JSON.stringify(item.value) 
							o[item.field] = '查看'
						}else{
							o[item.field] = item.value.toString()
						}
					}
				}
				if(item.field == 'a'){
					o[item.field] = '查看'
				}
				if(item.isfile){
					let subId = '',simpleClazzName='',fileId='',fieldId='',fileUplaodKey='';
					if (item.attr) { 
						if(item.attr.subId)
							subId = item.attr.subId
						if(item.attr.simpleClazzName)
							simpleClazzName = item.attr.simpleClazzName
						if(item.attr.fileId)
							fileId = item.attr.fileId
						if(item.attr.fieldId)
							fieldId = item.attr.fieldId
						if(item.fileUplaodKey)
							fileUplaodKey = item.fileUplaodKey
					}
					if(item.fileList){
						uni.setStorageSync('showFileList',item.fileList);
					}
					o['busCode'] = _that.busCode
					o['mainId'] = _that.formId
					o['subId'] = subId
					o['simpleClazzName'] = simpleClazzName
					o['fileId'] = fileId 
					o['fieldId'] = fieldId
					o['fileUplaodKey'] = fileUplaodKey
				}
			},
		},
		onLoad(options) {
			uni.setNavigationBarTitle({
				title:"企业数字运营管理"
			})
			let _that = this;
			_that.formId = options.fileId;
			_that.busCode = options.busCode;
			_that.orgId = options.orgId;
			_that.wechatHistoryId = options.wechatHistoryId
			if(!options.receiveUserName){
				_that.goToOld = true
			}
			if(options.isOuter !== null && options.isOuter !== undefined){
				_that.isOuter = options.isOuter;
			}
			
			// _that.formId = 355;
			// _that.busCode = "HRS1201";
			// _that.orgId = 1;
			// _that.isOuter = false;
			_that.loadFormInfo();
		},
		onUnload() {
			let _that = this
			uni.removeStorageSync(_that.storageKey)
		},
		onShow() {
			let _that = this
			try {
				const value = uni.getStorageSync(_that.storageKey);
				if (value) {
					_that.image = value
				}
				uni.removeStorageSync(_that.storageKey)
			}catch(e){
				
			}
		},
		onPageScroll(e) {
			let _that = this;
			_that.scrollTop = e.scrollTop;
			let fabButtons = _that.fabButtons;
			if (e.scrollTop > 5) {
				if (_that.fabButtons.length === 1) {
					fabButtons.unshift(app.globalData.button.top);
					_that.fabButtons = fabButtons;
				}
			} else {
				if (_that.fabButtons.length === 2) {
					fabButtons.shift();
					_that.fabButtons = fabButtons;
				}
			}
		},
		beforeDestroy() {
			clearInterval(this.timer)  
		},
	};
</script>
	
<style scoped>
	.wpopup-item-sign{
		border-bottom: 1px solid #EEEEEE;
		height: 150rpx;
	}
	.wpopup-item{
		border-bottom: 1px solid #EEEEEE;
	},
	.remarkTable >>> #remarkTable{
		border-collapse: collapse;
	}
	.remarkTable >>> #remarkTable tr td{
		border: 1px solid #CCCCCC;
		padding-left: 10px;
	}
	.remarkTable >>> #remarkTable tr td:nth-child(1) {
		width:75%;
	}
	.remarkTable >>> #remarkTable tr td:nth-child(2) {
		width:25%;
	}
	.show-title {
		font-size: 28rpx;
	}

	.om-show-hd {
		display: flex;
		justify-content: center;
		padding: 20rpx 0 15rpx 0;
	}

	.sub-title {
		margin: 20rpx;
		font-size: 28rpx;
		font-weight: 700;
		color: rgb(87, 85, 85);
	}
	.sub-title-des {
		margin: 20rpx;
		font-size: 24rpx;
		color: rgb(87, 85, 85);
	}
	.show-font-size{
		font-size:16px
	}
	.create-qrcode{
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		z-index: 99999;
	}
	.create-qrcode .bg{
		position: absolute;
		top: 0;
		left: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,0.5);
	}
	.canvascode{
		text-align: center;
		margin-top: 50%;
	}
	.canvascode canvas{
		margin: 0 auto;
	}
	.subbtn{
		line-height:30px; 
		width:80px; 
		height:30px;
		margin-right: 15px;
		color: #FFFFFF; 
		padding: 0;
	}
	.pageButon{
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		position:fixed;
		width: 94rpx;
		text-align: center;
		background-color: #5697F4;
		color: #FFFFFF; 
		z-index: 10;
		border-radius: 10rpx;
		font-size: 13px;
		opacity:0.8;
		padding:5px 0 5px 0 ;
	}
	.pageButonSon{
		display: flex;
		flex: 1; 
		flex-direction:column;
		justify-content: center;
	}
	.tip{
		margin-left: 24px;
		margin-bottom: 5px;
		width: 24px;
		height: 24px;
		background: url("@/static/images/others/aboutSlide.png") no-repeat;
		background-size: 24px 24px;
		position: absolute;
		right: 20px;
		top: 8px;
	}
	.confirmButon {
		height: 100%;
		width: 45%;
	}
	.confirmButon view{
		border-radius: 10rpx;
		text-align: center;
		font-size: 40rpx;
		width:100%;
		height: 100%;
		line-height: 100rpx;
		margin-left:0px;
		background-color:#5697F4;
		color: white;
	}
</style>
